<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1">
  <title>pgbouncer.ini</title>
  <body>
    <p>PgBouncer configuration file.</p>
    <section>
      <title>Synopsis</title>
      <codeblock>[databases]
db = ...

[pgbouncer]
...

[users]
...</codeblock>
    </section>
    <section>
      <title>Description</title>
      <p>You specify PgBouncer configuration parameters and identify user-specific configuration parameters in the <codeph>pgbouncer.ini</codeph> configuration file.</p>
      <p>The PgBouncer configuration file (typically named <codeph>pgbouncer.ini</codeph>)
        is specified in <codeph>.ini</codeph> format. Files in <codeph>.ini</codeph> format are composed of
        sections, parameters, and values. Section names are enclosed in square brackets,
        for example, <codeph>[<varname>section_name</varname>]</codeph>. Parameters and values are
        specified in <codeph><varname>key</varname>=<varname>value</varname></codeph>
        format. Lines beginning with a semicolon (<codeph>;</codeph>) or pound sign
        (<codeph>#</codeph>) are considered comment lines
        and are ignored.</p>
      <p>The PgBouncer configuration file can contain <codeph>%include</codeph> directives,
        which specify another file to read and process. This enables you to split the configuration
        file into separate parts. For example:<codeblock>%include filename</codeblock></p><p>If the filename provided is not an absolute path, the file system location is taken as relative to the current working directory.</p>
      <p>The PgBouncer configuration file includes the following sections, described in detail below:<ul id="ul_kwg_vll_gs">
        <li><xref href="#topic_fmd_ckd_gs" format="dita"/></li>
        <li><xref href="#topic_orc_gkd_gs" format="dita"/></li>
        <li><xref href="#topic_lzk_zjd_gs" format="dita"/></li>
      </ul></p>
    </section>
  </body>

  <topic id="topic_fmd_ckd_gs">
    <title>[databases] Section</title>
    <body>
      <p>The <codeph>[databases]</codeph> section contains <codeph><varname>key</varname>=<varname>value</varname></codeph> pairs, where the <codeph><varname>key</varname></codeph> is a database name and
        the <codeph><varname>value</varname></codeph> is a <codeph>libpq</codeph> connect-string list of <codeph><varname>key</varname></codeph>=<codeph><varname>value</varname></codeph> pairs. </p>
      <p>A database name can contain characters <codeph>[0-9A-Za-z_.-]</codeph> without quoting.
        Names that contain other characters must be quoted with standard SQL identifier quoting:<ul
          id="ul_wzm_b4p_ts">
          <li>Enclose names in double quotes (<codeph>" "</codeph>).</li>
          <li>Represent a double-quote within an identifier with two consecutive double quote
            characters.</li>
        </ul></p>
      <p>The database name <codeph>*</codeph> is the fallback database. PgBouncer uses the
        value for this key as a connect string for the requested database. Automatically-created database entries
        such as these are cleaned up if they remain idle longer than the time specified in
          <codeph>autodb_idle_timeout</codeph> parameter.</p>
      <section>
        <title>Database Connection Parameters</title>
        <p>The following parameters may be included in the <codeph><varname>value</varname></codeph> to specify the location of the
          database. </p>
        <parml>
          <plentry>
            <pt>dbname</pt>
            <pd>The destination database name.<p>Default: the client-specified database
                name</p></pd>
          </plentry>
          <plentry>
            <pt>host</pt>
            <pd>The name or IP address of the Greenplum master host. Host names are resolved at
              connect time. If DNS returns several results, they are used in a round-robin
              manner. The DNS result is cached and the <codeph>dns_max_ttl</codeph> parameter
              determines when the cache entry expires. </pd>
            <pd>
              <p>Default: not set; the connection is made through a Unix socket</p>
            </pd>
          </plentry>
          <plentry>
            <pt>port</pt>
            <pd>The Greenplum Database master port.</pd>
            <pd><p>Default: 5432</p></pd>
          </plentry>
          <plentry>
            <pt>user, password</pt>
            <pd>If <codeph>user=</codeph> is set, all connections to the destination database
              are initiated as the specified user, resulting in a single connection pool for
               the database.<p>If the <codeph>user=</codeph> parameter is not set, PgBouncer
                attempts to log in to the destination database with the user name passed by the
                client. In this situation, there will be one pool for each user who connects to the
                database.</p></pd>
          </plentry>
          <plentry>
            <pt>auth_user</pt>
            <pd>If <codeph>auth_user</codeph> is set, any user who is not specified in
                <codeph>auth_file</codeph> is authenticated by querying the
                <codeph>pg_shadow</codeph> database view. PgBouncer performs this
                query as the
                <codeph>auth_user</codeph> Greenplum Database user. <codeph>auth_user</codeph>'s password must be set
              in the <codeph>auth_file</codeph>.</pd>
          </plentry>
          <plentry>
            <pt>client_encoding</pt>
            <pd>Ask for specific <codeph>client_encoding</codeph> from server.</pd>
          </plentry>
          <plentry>
            <pt>datestyle</pt>
            <pd>Ask for specific <codeph>datestyle</codeph> from server.</pd>
          </plentry>
          <plentry>
            <pt>timezone</pt>
            <pd>Ask for specific <codeph>timezone</codeph> from server.</pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Pool Configuration</title>
        <p>You can use the following parameters for database-specific pool configuration.</p>
        <parml>
          <plentry>
            <pt>pool_size</pt>
            <pd>Set the maximum size of pools for this database. If not set, the
                <codeph>default_pool_size</codeph> is used.</pd>
          </plentry>
          <plentry>
            <pt>connect_query</pt>
            <pd>Query to be run after a connection is established, but before allowing the
              connection to be used by any clients. If the query raises errors, they are logged
              but ignored otherwise.</pd>
          </plentry>
          <plentry>
            <pt>pool_mode</pt>
            <pd>Set the pool mode for this database. If not set, the default
                <codeph>pool_mode</codeph> is used.</pd>
          </plentry>
          <plentry>
            <pt>max_db_connections</pt>
            <pd>Set a database-wide maximum number of PgBouncer connections for this
              database. The total number of connections for all pools for this database
              will not exceed this value.
            </pd>
          </plentry>
        </parml>
      </section>
    </body>
  </topic>

  <topic id="topic_orc_gkd_gs">
    <title>[pgbouncer] Section</title>
    <body>
      <section>
        <title>Generic Settings</title>
        <parml>
          <plentry>
            <pt>logfile</pt>
            <pd>The location of the log file. The log file is kept open. After log
              rotation, run <codeph>kill -HUP pgbouncer</codeph> or run the <codeph>RELOAD;</codeph>
              command in the PgBouncer Administration Console. <p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>pidfile</pt>
            <pd>The name of the pid file. Without a pidfile, you cannot run PgBouncer as a
              background (daemon) process.<p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>listen_addr</pt>
            <pd>A list of interface addresses where PgBouncer listens for TCP connections. You
              may also use <codeph>*</codeph>, which means to listen on all interfaces. If not
              set, only Unix socket connections are allowed.<p>Specify addresses
                numerically (IPv4/IPv6) or by name.</p><p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>listen_port</pt>
            <pd>The port PgBouncer listens on. Applies to both TCP and Unix sockets.<p>Default:
                6432</p></pd>
          </plentry>
          <plentry>
            <pt>unix_socket_dir</pt>
            <pd>Specifies the location for the Unix sockets. Applies to both listening socket and server
              connections. If set to an empty string, Unix sockets are disabled. Required for
              online restart (<codeph>-R</codeph> option) to work.
              <p>Default: <codeph>/tmp</codeph></p></pd>
          </plentry>
          <plentry>
            <pt>unix_socket_mode</pt>
            <pd>Filesystem mode for the Unix socket.<p>Default: 0777</p></pd>
          </plentry>
          <plentry>
            <pt>unix_socket_group</pt>
            <pd>Group name to use for Unix socket.<p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>user</pt>
            <pd>If set, specifies the Unix user to change to after startup. This works only if
              PgBouncer is started as root or if <codeph>user</codeph> is the same as the
              current user.<p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>auth_file</pt>
            <pd>The name of the file containing the user names and passwords to load. The file
              format is the same as the Greenplum Database <filepath>pg_auth</filepath>
              file.<p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>auth_hba_file</pt>
            <pd>HBA configuration file to use when <codeph>auth_type</codeph> is <codeph>hba</codeph>. Refer to the <xref href="https://pgbouncer.github.io/config.html#hba-file-format" format="html" scope="external">HBA file format
          </xref> discussion in the PgBouncer documentation for information about PgBouncer support of the HBA authentication file format.<p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>auth_type</pt>
            <pd>How to authenticate users.<parml>
                <plentry>
                  <pt>pam</pt>
                  <pd>Use PAM to authenticate users. <codeph>auth_file</codeph> is ignored.
                    This method is not compatible with databases using the <codeph>auth_user</codeph> option. The service name reported to PAM is “pgbouncer”. PAM is not supported in the HBA configuration file.
                    </pd>
                </plentry>
                <plentry>
                  <pt>hba</pt>
                  <pd>The actual authentication type is loaded from the <codeph>auth_hba_file</codeph>. This setting allows different authentication methods different access paths.
                    </pd>
                </plentry>
                <plentry>
                  <pt>cert</pt>
                  <pd>Clients must connect with TLS using a valid client certificate. The
                    client's username is taken from CommonName field in the certificate.</pd>
                </plentry>
                <plentry>
                  <pt>md5</pt>
                  <pd>Use MD5-based password check. <codeph>auth_file</codeph> may contain both
                    MD5-encrypted or plain-text passwords. This is the default authentication
                    method.</pd>
                </plentry>
                <plentry>
                  <pt>plain</pt>
                  <pd>Clear-text password is sent over wire. <i>Deprecated</i>.</pd>
                </plentry>
                <plentry>
                  <pt>trust</pt>
                  <pd>No authentication is performed. The username must still exist in the
                      <codeph>auth_file</codeph>.</pd>
                </plentry>
                <plentry>
                  <pt>any</pt>
                  <pd>Like the <codeph>trust</codeph> method, but the username supplied is
                    ignored. Requires that all databases are configured to log in with a
                    specific user. Additionally, the console database allows any user to log in
                    as admin.</pd>
                </plentry>
              </parml></pd>
          </plentry>
          <plentry>
            <pt>auth_query</pt>
            <pd>Query to load a user's password from the database. If a user does not exist in the
                <codeph>auth_file</codeph> and the database entry includes an
                <codeph>auth_user</codeph>, this query is run in the database as
                <codeph>auth_user</codeph> to lookup up the user.<p>Note that the query is run inside target database, so if a function is used it needs to be installed into each database.</p><p>Default: <codeph>SELECT
                  usename, passwd FROM pg_shadow WHERE usename=$1</codeph></p></pd>
          </plentry>
          <plentry>
            <pt>auth_user</pt>
            <pd>If <codeph>auth_user</codeph> is set, any user who is not specified in
                <codeph>auth_file</codeph> is authenticated through the 
                <codeph>auth_query</codeph> query from the <codeph>pg_shadow</codeph> database view. PgBouncer performs this
                query as the
                <codeph>auth_user</codeph> Greenplum Database user. <codeph>auth_user</codeph>'s password must be set
              in the <codeph>auth_file</codeph>.<p>Direct access to <codeph>pg_shadow</codeph> requires Greenplum Database administrative privileges. It is preferable to use a non-admin user that calls <codeph>SECURITY DEFINER</codeph> function instead.</p></pd>
          </plentry>
          <plentry>
            <pt>pool_mode</pt>
            <pd>Specifies when a server connection can be reused by other clients.<parml>
                <plentry>
                  <pt>session</pt>
                  <pd>Connection is returned to the pool when the client disconnects.
                    Default.</pd>
                </plentry>
                <plentry>
                  <pt>transaction</pt>
                  <pd>Connection is returned to the pool when the transaction finishes.</pd>
                </plentry>
                <plentry>
                  <pt>statement</pt>
                  <pd>Connection is returned to the pool when the current query finishes. Long
                    transactions with multiple statements are disallowed in this mode.</pd>
                </plentry>
              </parml></pd>
          </plentry>
          <plentry>
            <pt>max_client_conn</pt>
            <pd>Maximum number of client connections allowed. When increased, you should also increase the file
              descriptor limits. The actual number of file descriptors
              used is more than <codeph>max_client_conn</codeph>. The theoretical maximum used,
              when each user connects with its own username to the server
                is:<codeblock>max_client_conn + (max_pool_size * total_databases * total_users)</codeblock><p>
                If a database user is specified in the connect string, all users connect using
                the same username. Then the theoretical maximum connections
                is:</p><codeblock>max_client_conn + (max_pool_size * total_databases)</codeblock><p>(The
                theoretical maximum should be never reached, unless someone deliberately crafts a
                load for it. Still, it means you should set the number of file descriptors to a
                safely high number. Search for <codeph>ulimit</codeph> in your operating system
                documentation.)</p><p>Default: 100</p></pd>
          </plentry>
          <plentry>
            <pt>default_pool_size</pt>
            <pd>The number of server connections to allow per user/database pair. This can be
              overridden in the per-database configuration.<p>Default: 20</p></pd>
          </plentry>
          <plentry>
            <pt>min_pool_size</pt>
            <pd>Add more server connections to the pool when it is lower than this number. This
              improves behavior when the usual load drops and then returns suddenly after a
              period of total inactivity.<p>Default: 0 (disabled)</p></pd>
          </plentry>
          <plentry>
            <pt>reserve_pool_size</pt>
            <pd>The number of additional connections to allow for a pool. 0 disables.<p>Default:
                0 (disabled)</p></pd>
          </plentry>
          <plentry>
            <pt>reserve_pool_timeout</pt>
            <pd>If a client has not been serviced in this many seconds, PgBouncer enables use of
              additional connections from the reserve pool. 0 disables.<p>Default: 5.0</p></pd>
          </plentry>
          <plentry>
            <pt>max_db_connections</pt>
            <pd>The maximum number of connections per database. If you hit the limit, closing a
              client connection to one pool does not immediately allow a server connection to be
              established for another pool, because the server connection for the first pool is
              still open. Once the server connection closes (due to idle timeout), a new server
              connection will be opened for the waiting pool.<p>Default: unlimited</p></pd>
          </plentry>
          <plentry>
            <pt>max_user_connections</pt>
            <pd>The maximum number of connections per-user. When you hit the limit, closing a
              client connection to one pool does not immediately allow a connection to be
              established for another pool, because the connection for the first pool is still
              open. After the connection for the first pool has closed (due to idle timeout), a
              new server connection is opened for the waiting pool.</pd>
          </plentry>
          <plentry>
            <pt>server_round_robin</pt>
            <pd>By default, PgBouncer reuses server connections in LIFO (last-in, first-out)
              order, so that a few connections get the most load. This provides the best
              performance when a single server serves a database. But if there is TCP
              round-robin behind a database IP, then it is better if PgBouncer also uses
              connections in that manner to achieve uniform load.<p>Default: 0</p></pd>
          </plentry>
          <plentry>
            <pt>ignore_startup_parameters</pt>
            <pd>By default, PgBouncer allows only parameters it can keep track of in startup
              packets: <codeph>client_encoding</codeph>, <codeph>datestyle</codeph>,
                <codeph>timezone</codeph>, and
                <codeph>standard_conforming_strings</codeph>.<p>All others parameters raise an
                error. To allow other parameters, specify them here so that PgBouncer can ignore
                them.</p><p>Default: empty</p></pd>
          </plentry>
          <plentry>
            <pt>disable_pqexec</pt>
            <pd>Disable Simple Query protocol (PQexec). Unlike Extended Query protocol, Simple
              Query protocol allows multiple queries in one packet, which allows some classes of
              SQL-injection attacks. Disabling it can improve security. This means that only
              clients that exclusively use Extended Query protocol will work.<p>Default:
              0</p></pd>
          </plentry>
          <plentry>
            <pt>application_name_add_host</pt>
            <pd>Add the client host address and port to the application name setting set on
              connection start. This helps in identifying the source of bad queries. The setting
              is overwritten without detection if the application runs <codeph>SET
                application_name</codeph> after connecting. <p>Default: 0</p></pd>
          </plentry>
          <plentry>
            <pt>conffile</pt>
            <pd>Show location of the current configuration file. Changing this parameter will result in PgBouncer using another config file for next RELOAD / SIGHUP.
                <p>Default: file from command line</p></pd>
          </plentry>
          <plentry>
            <pt>service_name</pt>
            <pd>Used during win32 service registration.
                <p>Default: pgbouncer</p></pd>
          </plentry>
          <plentry>
            <pt>job_name</pt>
            <pd>Alias for <codeph>service_name</codeph>.</pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Log Settings</title>
        <parml>
          <plentry>
            <pt>syslog</pt>
            <pd>Toggles syslog on and off.<p>Default:
                0</p></pd>
          </plentry>
          <plentry>
            <pt>syslog_ident</pt>
            <pd>Under what name to send logs to syslog.<p>Default:
                <codeph>pgbouncer</codeph></p></pd>
          </plentry>
          <plentry>
            <pt>syslog_facility</pt>
            <pd>Under what facility to send logs to syslog. Some possibilities are:
                <codeph>auth</codeph>, <codeph>authpriv</codeph>, <codeph>daemon</codeph>,
                <codeph>user</codeph>, <codeph>local0-7</codeph><p>Default:
                  <codeph>daemon</codeph></p></pd>
          </plentry>
          <plentry>
            <pt>log_connections</pt>
            <pd>Log successful logins.<p>Default: 1</p></pd>
          </plentry>
          <plentry>
            <pt>log_disconnections</pt>
            <pd>Log disconnections, with reasons.<p>Default: 1</p></pd>
          </plentry>
          <plentry>
            <pt>log_pooler_errors</pt>
            <pd>Log error messages that the pooler sends to clients.<p>Default: 1</p></pd>
          </plentry>
          <plentry>
            <pt>log_stats</pt>
            <pd>Write aggregated statistics into the log, every <codeph>stats_period</codeph>. This
              can be disabled if external monitoring tools are used to grab the same data from
                <codeph>SHOW</codeph> commands.<p>Default: 1</p>
            </pd>
          </plentry>
          <plentry>
            <pt>stats_period</pt>
            <pd>How often to write aggregated statistics to the log. <p>Default: 60</p></pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Console Access Control</title>
        <parml>
          <plentry>
            <pt>admin_users</pt>
            <pd>Comma-separated list of database users that are allowed to connect and run all
              commands on the PgBouncer Administration Console. Ignored when <codeph>auth_type=any</codeph>, in which case
              any username is allowed in as admin.<p>Default: empty</p></pd>
          </plentry>
          <plentry>
            <pt>stats_users</pt>
            <pd>Comma-separated list of database users that are allowed to connect and run
              read-only queries on the console. This includes all <codeph>SHOW</codeph> commands except <codeph>SHOW
                FDS</codeph>.<p>Default: empty</p></pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Connection Sanity Checks, Timeouts</title>
        <parml>
          <plentry>
            <pt>server_reset_query</pt>
            <pd>Query sent to server on connection release, before making it available to other
              clients. At that moment no transaction is in progress so it should not include
                <codeph>ABORT</codeph> or <codeph>ROLLBACK</codeph>.<p>The query should clean any
                changes made to a database session so that the next client gets a connection in a
                well-defined state. Default is <codeph>DISCARD ALL</codeph> which cleans everything,
                but that leaves the next client no pre-cached state.
                <note>Greenplum Database does not support <codeph>DISCARD ALL</codeph>.
                </note></p><p>You can use other commands to clean up the session state. For example,
                  <codeph>DEALLOCATE ALL</codeph> drops prepared statements, and <codeph>DISCARD
                  TEMP</codeph> drops temporary tables. </p><p>When transaction pooling is used, the
                  <codeph>server_reset_query</codeph> should be empty, as clients should not use any
                session features. If clients do use session features, they will be broken because
                transaction pooling does not guarantee that the next query will run on the same
                connection.</p><p>Default: <codeph>DISCARD ALL;</codeph> (Not supported by Greenplum
                Database.)</p></pd>
          </plentry>
          <plentry>
            <pt>server_reset_query_always</pt>
            <pd>
              <p>Whether <codeph>server_reset_query</codeph> should be run in all pooling modes.
                When this setting is off (default), the <codeph>server_reset_query</codeph> will be
                run only in pools that are in sessions pooling mode. Connections in transaction
                pooling mode should not have any need for reset query.</p>
              <p>Default: 0</p>
            </pd>
          </plentry>
          <plentry>
            <pt>server_check_delay</pt>
            <pd>How long to keep released connections available for re-use without running
              sanity-check queries on it. If 0, then the query is run always.<p>Default:
              30.0</p></pd>
          </plentry>
          <plentry>
            <pt>server_check_query</pt>
            <pd>A simple do-nothing query to test the server connection.<p>If an empty string,
                then sanity checking is disabled.</p><p>Default: SELECT 1;</p></pd>
          </plentry>
          <plentry>
            <pt>server_fast_close</pt>
            <pd>Disconnect a server in session pooling mode immediately or after the end of the
              current transaction if it is in “close_needed” mode (set by
              <codeph>RECONNECT</codeph>, <codeph>RELOAD</codeph> that changes connection settings,
              or DNS change), rather than waiting for the session end. In statement or transaction
              pooling mode, this has no effect since that is the default behavior there.<p>If
                because of this setting a server connection is closed before the end of the client
                session, the client connection is also closed. This ensures that the client notices
                that the session has been interrupted.</p><p>This setting makes connection
                configuration changes take effect sooner if session pooling and long-running
                sessions are used. The downside is that client sessions are liable to be interrupted
                by a configuration change, so client applications will need logic to reconnect and
                reestablish session state. But note that no transactions will be lost, because
                running transactions are not interrupted, only idle sessions.</p><p>Default:
              0</p></pd>
          </plentry>
          <plentry>
            <pt>server_lifetime</pt>
            <pd>The pooler tries to close server connections that have been connected longer
              than this number of seconds. Setting it to 0 means the connection is to be used
              only once, then closed.<p>Default: 3600.0</p></pd>
          </plentry>
          <plentry>
            <pt>server_idle_timeout</pt>
            <pd>If a server connection has been idle more than this many seconds it is dropped.
              If this parameter is set to 0, timeout is disabled. [seconds]<p>Default:
              600.0</p></pd>
          </plentry>
          <plentry>
            <pt>server_connect_timeout</pt>
            <pd>If connection and login will not finish in this number of seconds, the
              connection will be closed. <p>Default: 15.0</p></pd>
          </plentry>
          <plentry>
            <pt>server_login_retry</pt>
            <pd>If a login fails due to failure from <codeph>connect()</codeph> or
              authentication, the pooler waits this many seconds before retrying to connect.
                <p>Default: 15.0</p></pd>
          </plentry>
          <plentry>
            <pt>client_login_timeout</pt>
            <pd>If a client connects but does not manage to login in this number of seconds, it
              is disconnected. This is needed to avoid dead connections stalling
                <codeph>SUSPEND</codeph> and thus online restart.<p>Default: 60.0</p></pd>
          </plentry>
          <plentry>
            <pt>autodb_idle_timeout</pt>
            <pd>If database pools created automatically (via <codeph>*</codeph>) have been unused this many
              seconds, they are freed. Their statistics are also forgotten. <p>Default:
                3600.0</p></pd>
          </plentry>
          <plentry>
            <pt>dns_max_ttl</pt>
            <pd>How long to cache DNS lookups, in seconds. If a DNS lookup returns several
              answers, PgBouncer round-robins between them in the meantime. The actual DNS TTL
              is ignored. <p>Default: 15.0</p></pd>
          </plentry>
          <plentry>
            <pt>dns_nxdomain_ttl</pt>
            <pd>How long error and NXDOMAIN DNS lookups can be cached, in seconds.<p>Default:
                15.0</p></pd>
          </plentry>
          <plentry>
            <pt>dns_zone_check_period</pt>
            <pd>Period to check if zone serial numbers have changed.<p>PgBouncer can collect DNS
                zones from hostnames (everything after first dot) and then periodically check if
                the zone serial numbers change. If changes are detected, all hostnames in that
                zone are looked up again. If any host IP changes, its connections are
                invalidated.</p><p>Works only with UDNS and c-ares backend (<codeph>--with-udns</codeph> or <codeph>--with-cares</codeph> to
                configure).</p><p>Default: 0.0 (disabled)</p></pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>TLS settings</title>
        <parml>
          <plentry><pt>client_tls_sslmode</pt><pd>TLS mode to use for connections from clients. TLS connections are disabled by default. When enabled, <codeph>client_tls_key_file</codeph> and <codeph>client_tls_cert_file</codeph> must be also configured to set up the key and certificate PgBouncer uses to accept client connections.<ul id="ul_dgn_drd_bt">
            <li><codeph>disable</codeph>: Plain TCP. If client requests TLS, it’s ignored. Default.</li>
            <li><codeph>allow</codeph>: If client requests TLS, it is used. If not, plain TCP is used. If client uses client-certificate, it is not validated.</li>
            <li><codeph>prefer</codeph>: Same as <codeph>allow</codeph>.</li>
            <li><codeph>require</codeph>: Client must use TLS. If not, client connection is rejected. If client uses client-certificate, it is not validated.</li>
            <li><codeph>verify-ca</codeph>: Client must use TLS with valid client certificate.</li>
            <li><codeph>verify-full</codeph>: Same as <codeph>verify-ca</codeph>.</li></ul></pd>
          </plentry>
          <plentry><pt>client_tls_key_file</pt><pd>Private key for PgBouncer to accept client connections.</pd><pd><p>Default: not set</p></pd>
          </plentry>
          <plentry><pt>client_tls_cert_file</pt><pd>Root certificate file to validate client certificates.</pd><pd><p>Default: unset</p></pd>
          </plentry>
          <plentry><pt>client_tls_ca_file</pt><pd>Root certificate to validate client certificates.</pd><pd><p>Default: unset</p></pd></plentry>
          <plentry><pt>client_tls_protocols</pt><pd>Which TLS protocol versions are allowed. </pd><pd>Valid values: are <codeph>tlsv1.0</codeph>, <codeph>tlsv1.1</codeph>, <codeph>tlsv1.2</codeph>. </pd><pd>Shortcuts: <codeph>all</codeph> (<codeph>tlsv1.0</codeph>,<codeph>tlsv1.1</codeph>,<codeph>tlsv1.2</codeph>), <codeph>secure</codeph> (<codeph>tlsv1.2</codeph>), <codeph>legacy</codeph> (<codeph>all</codeph>).</pd><pd><p>Default: <codeph>secure</codeph></p></pd>
          </plentry>
          <plentry><pt>client_tls_ciphers</pt><pd><p>Default: <codeph>fast</codeph></p></pd>
          </plentry>
          <plentry><pt>client_tls_ecdhcurve</pt><pd>Elliptic Curve name to use for ECDH key exchanges.</pd><pd>Allowed values: <codeph>none</codeph> (DH is disabled), <codeph>auto</codeph> (256-bit ECDH), curve name.</pd><pd><p>Default: <codeph>auto</codeph></p></pd>
          </plentry>
          <plentry><pt>client_tls_dheparams</pt><pd>DHE key exchange type.</pd><pd>Allowed values: <codeph>none</codeph> (DH is disabled), <codeph>auto</codeph> (2048-bit DH), <codeph>legacy</codeph> (1024-bit DH).</pd><pd><p>Default: <codeph>auto</codeph></p></pd>
          </plentry>
          <plentry><pt>server_tls_sslmode</pt><pd>TLS mode to use for connections to Greenplum Database and PostgreSQL servers. TLS connections are disabled by default.<ul id="ul_hyh_1td_bt">
            <li><codeph>disabled</codeph>: Plain TCP. TLS is not requested from the server. Default.</li>
            <li><codeph>allow</codeph>: If server rejects plain, try TLS. (<i>PgBouncer Documentation is speculative on this..</i>)</li>
            <li><codeph>prefer</codeph>: TLS connection is always requested first. When connection is refused, plain TPC is used. Server certificate is not validated.</li>
            <li><codeph>require</codeph>: Connection must use TLS. If server rejects it, plain TCP is not attempted. Server certificate is not validated.</li>
            <li><codeph>verify-ca</codeph>: Connection must use TLS and server certificate must be valid according to <codeph>server_tls_ca_file</codeph>. The server hostname is not verfied against the certificate.</li>
            <li><codeph>verify-full</codeph>: Connection must use TLS and the server certificate must be valid according to <codeph>server_tls_ca_file</codeph>. The server hostname must match the hostname in the certificate.</li></ul></pd>
          </plentry>
          <plentry><pt>server_tls_ca_file</pt><pd>Path to the root certificate file used to validate Greenplum Database and PostgreSQL server certificates.</pd><pd><p>Default: unset</p></pd>
          </plentry>
          <plentry><pt>server_tls_key_file</pt><pd>The private key for PgBouncer to authenticate against Greenplum Database or PostgreSQL server.</pd><pd><p>Default: not set</p></pd>
          </plentry>
          <plentry><pt>server_tls_cert_file</pt><pd>Certificate for private key. Greenplum Database or PostgreSQL servers can validate it.</pd><pd><p>Default: not set</p></pd>
          </plentry>
          <plentry><pt>server_tls_protocols</pt><pd>Which TLS protocol versions are allowed. </pd><pd>Valid values are: <codeph>tlsv1.0</codeph>, <codeph>tlsv1.1</codeph>, <codeph>tlsv1.2</codeph>. </pd><pd>Shortcuts: <codeph>all</codeph> (<codeph>tlsv1.0</codeph>, <codeph>tlsv1.1</codeph>, <codeph>tlsv1.2</codeph>); <codeph>secure</codeph> (<codeph>tlsv1.2</codeph>); <codeph>legacy</codeph> (<codeph>all</codeph>).</pd><pd><p>Default: <codeph>secure</codeph></p></pd>
          </plentry>
          <plentry><pt>server_tls_ciphers</pt><pd><p>Default: <codeph>fast</codeph></p></pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Dangerous Timeouts</title>
        <p>Setting the following timeouts can cause unexpected errors.</p>
        <parml>
          <plentry>
            <pt>query_timeout</pt>
            <pd>Queries running longer than this (seconds) are canceled. This parameter should
              be used only with a slightly smaller server-side
                <codeph>statement_timeout</codeph>, to trap queries with network problems.
                [seconds]<p>Default: 0.0 (disabled)</p></pd>
          </plentry>
          <plentry>
            <pt>query_wait_timeout</pt>
            <pd>The maximum time, in seconds, queries are allowed to wait for execution. If the
              query is not assigned a connection during that time, the client is disconnected.
              This is used to prevent unresponsive servers from grabbing up
                connections.<p>Default: 120</p></pd>
          </plentry>
          <plentry>
            <pt>client_idle_timeout</pt>
            <pd>Client connections idling longer than this many seconds are closed. This should
              be larger than the client-side connection lifetime settings, and only used for
              network problems.<p>Default: 0.0 (disabled)</p></pd>
          </plentry>
          <plentry>
            <pt>idle_transaction_timeout</pt>
            <pd>If client has been in "idle in transaction" state longer than this (seconds), it
              is disconnected. <p>Default: 0.0 (disabled)</p></pd>
          </plentry>
        </parml>
      </section>
      <section>
        <title>Low-level Network Settings</title>
        <parml>
          <plentry>
            <pt>pkt_buf</pt>
            <pd>Internal buffer size for packets. Affects the size of TCP packets sent and
              general memory usage. Actual <codeph>libpq</codeph> packets can be larger than this so there is no
              need to set it large.<p>Default: 4096</p></pd>
              </plentry>
          <plentry>
            <pt>max_packet_size</pt>
            <pd>Maximum size for packets that PgBouncer accepts. One packet is either one query
              or one result set row. A full result set can be larger.<p>Default:
              2147483647</p></pd>
          </plentry>
          <plentry>
            <pt>listen_backlog</pt>
            <pd>Backlog argument for the <codeph>listen(2)</codeph> system call. It determines how many new
              unanswered connection attempts are kept in queue. When the queue is full, further
              new connection attempts are dropped.<p>Default: 128</p></pd>
          </plentry>
          <plentry>
            <pt>sbuf_loopcnt</pt>
            <pd>How many times to process data on one connection, before proceeding. Without
              this limit, one connection with a big result set can stall PgBouncer for a long
              time. One loop processes one <codeph>pkt_buf</codeph> amount of data. 0 means no
                limit.<p>Default: 5</p></pd>
          </plentry>
          <plentry>
            <pt>SO_REUSEPORT</pt>
            <pd>Specifies whether to set the socket option <codeph>SO_REUSEPORT</codeph> on TCP
              listening sockets. On some operating systems, this allows running multiple PgBouncer
              instances on the same host listening on the same port and having the kernel distribute
              the connections automatically. This option is a way to get PgBouncer to use more CPU
              cores. (PgBouncer is single-threaded and uses one CPU core per instance.)<p>The
                behavior in detail depends on the operating system kernel. As of this writing, this
                setting has the desired effect on recent versions of Linux. On systems that don’t
                support the socket option at all, turning this setting on will result in an
                error.</p><p>Each PgBouncer instance on the same host needs different settings for
                at least <codeph>unix_socket_dir</codeph> and <codeph>pidfile</codeph>, as well as
                  <codeph>logfile</codeph> if that is used. Also note that if you make use of this
                option, you can no longer connect to a specific PgBouncer instance via TCP/IP, which
                might have implications for monitoring and metrics collection.</p><p>Default:
              0</p></pd>
          </plentry>
          <plentry>
            <pt>suspend_timeout</pt>
            <pd>How many seconds to wait for buffer flush during <codeph>SUSPEND</codeph> or
              restart (<codeph>-R</codeph>). Connection is dropped if flush does not
                succeed.<p>Default: 10</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_defer_accept</pt>
            <pd>For details on this and other TCP options, please see the tcp(7) man
                page.<p>Default: 45 on Linux, otherwise 0</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_socket_buffer</pt>
            <pd><p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_keepalive</pt>
            <pd>Turns on basic keepalive with OS defaults.<p>On Linux, the system defaults are
                  <codeph>tcp_keepidle=7200</codeph>, <codeph>tcp_keepintvl=75</codeph>,
                  <codeph>tcp_keepcnt=9</codeph>. </p><p>Default: 1</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_keepcnt</pt>
            <pd><p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_keepidle</pt>
            <pd><p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_keepintvl</pt>
            <pd><p>Default: not set</p></pd>
          </plentry>
          <plentry>
            <pt>tcp_user_timeout</pt>
            <pd>Sets the <codeph>TCP_USER_TIMEOUT</codeph> socket option. This specifies the maximum
              amount of time in milliseconds that transmitted data may remain unacknowledged before
              the TCP connection is forcibly closed. If set to 0, then operating system’s default is
                used.<p>Default: 0</p>
            </pd>
          </plentry>
        </parml>
      </section>
    </body>
  </topic>

  <topic id="topic_lzk_zjd_gs">
    <title>[users] Section</title>
    <body>
      <p>This section contains <codeph><varname>key</varname></codeph>=<codeph><varname>value</varname></codeph> pairs, where the <codeph><varname>key</varname></codeph> is a user name and the
        <codeph><varname>value</varname></codeph> is a <codeph>libpq</codeph> connect-string list of <codeph><varname>key</varname></codeph>=<codeph><varname>value</varname></codeph> pairs. </p>
      <p>
        <b>Pool configuration</b>
      </p>
      <parml>
        <plentry>
          <pt>pool_mode</pt>
          <pd>Set the pool mode for all connections from this user. If not set, the
            database or default <codeph>pool_mode</codeph> is used.</pd>
        </plentry>
      </parml>
    </body>
  </topic>

  <topic id="topic_xw4_dtc_gs">
    <title>Example Configuration Files</title>
    <body>
      <p>
        <b>Minimal Configuration</b>
      </p>
      <codeblock>[databases]
postgres = host=127.0.0.1 dbname=postgres auth_user=gpadmin

[pgbouncer]
pool_mode = session
listen_port = 6543
listen_addr = 127.0.0.1
auth_type = md5
auth_file = users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = someuser
stats_users = stat_collector
</codeblock>
        <p>Use connection parameters passed by the client:</p>
        <codeblock>[databases]
* =

[pgbouncer]
listen_port = 6543
listen_addr = 0.0.0.0
auth_type = trust
auth_file = bouncer/users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
ignore_startup_parameters=options</codeblock>
        <p>
          <b>Database Defaults</b>
        </p>
        <codeblock>[databases]

; foodb over unix socket
foodb =

; redirect bardb to bazdb on localhost
bardb = host=127.0.0.1 dbname=bazdb

; access to destination database will go with single user
forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO
</codeblock>
    </body>
  </topic>
  <topic id="seealso">
    <title>See Also</title>
    <body>
      <p><codeph><xref href="pgbouncer.xml#topic1" type="topic" format="dita"/></codeph>,
          <codeph><xref href="pgbouncer-admin.xml#topic1" type="topic" format="dita"/></codeph>, <xref href="https://pgbouncer.github.io/config.html" format="html" scope="external">PgBouncer Configuration Page</xref></p>
      </body>
  </topic>

</topic>
